package com.chenju.invokechainservice.domain;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Relationship;

import java.util.ArrayList;
import java.util.List;

@Node
@Data
@EqualsAndHashCode(callSuper = true)
public class TClassNode extends BaseNode{

    private boolean isController;

    private boolean isFeignClient;

    private boolean isAspect;

    private String mappingPath;

    private String superApplication;

    private String applicationName;

    @Relationship(type = "CONTAINS", direction = Relationship.Direction.OUTGOING)
    private List<TMethodNode> methods;

    @Relationship(type = "CONFIGURED", direction = Relationship.Direction.INCOMING)
    private List<TClassNode> configClasses;

    @Relationship(type = "ANNOTATED", direction = Relationship.Direction.INCOMING)
    private List<TAnnotationNode> annotations;

    public TClassNode() {
        super();
        this.configClasses = new ArrayList<>();
        this.annotations = new ArrayList<>();

    }

    public TClassNode(String name) {
        super(name);
        this.methods = new ArrayList<>();
        this.configClasses = new ArrayList<>();
        this.annotations = new ArrayList<>();
    }

    public void updateConfigClass(TClassNode node) {
        this.configClasses.add(node);
    }

}
